﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace background.Manager.Enterprise.Forms.Action {
    /// <summary>
    /// Temp 的摘要说明
    /// </summary>
    public class Temp: IHttpHandler {

        public void ProcessRequest(HttpContext context) {

            context.Response.ContentType = "text/plain";
            HttpRequest r=context.Request;
            string ret=string.Empty;
            switch(r["action"].ToString()) {
                case "AddTitle":
                    switch(r["format"].ToString()) {
                        case "text":
                        case "full":
                        case "date":
                        case "textarea":
                        case "upload":
                            ret= Codes.Forms.addTitle(r["serviceid"], r["format"], r["name"], string.Empty, r["Required"], r["Regx"], r["Display"]).ToString().ToLower();
                            break;
                        case "radio":
                        case "checkbox":
                            ret=Codes.Forms.addTitle(r["serviceid"], r["format"], r["name"], r["list"], r["Required"], string.Empty, r["Display"]).ToString().ToLower();
                            break;
                    }
                    break;
                case "CreateTable"://创建表
                    ret=Codes.Forms.CreateTest_ReturnId(r["name"], r["desc"]);
                    break;
                case "getGroup":
                    ret=Codes.h.getJson(Codes.Forms.getInfo(r["id"]));
                    break;
                case "deleteTemp":
                    ret= Codes.Forms.deleteMassTemp(r["GroupId"], r["idList"]).ToString().ToLower();
                    break;
                case "changeTemp":
                    ret= Codes.Forms.changeTemp(r["colm"], r["data"], int.Parse(r["id"])).ToString().ToLower();
                    break;
                case "deleteGroup":
                    ret= Codes.Forms.deleteMassGroup(r["idList"]).ToString().ToLower();
                    break;
                case "changeGroup":
                    ret= Codes.Forms.changeGroup(r["name"], r["desc"], int.Parse(r["id"])).ToString().ToLower();
                    break;
                case "changeTemps":
                    ret=Codes.Forms.changeTemp(r["title"], r["list"], r["display"], r["required"], r["regx"], int.Parse(r["id"])).ToString();
                    break;
                case "getTemp":
                    ret=Codes.h.getJson(Codes.Forms.getTemp(r["id"]));
                    break;
            }
            context.Response.Write(ret);
        }

        public bool IsReusable {
            get {
                return false;
            }
        }
    }
}